#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
ll cnt, sum;
int main()
{
	int time;
	cin >> time;
	while (time--)
	{
		cin >> s;
		int n = s.size();
		cnt = 1;
		sum = 0;
		for (int i = 0; i < n; i++)
		{
			if (s[i] == s[i + 1])
				cnt++;
			else
			{
				ll t = cnt;
				ll x = 0;
				while (t)
				{
					x++;
					t /= 10;
				}
				sum += x + 1;
				cnt = 1;
			}
		}
		if (sum == n)
			cout << "not compress" << endl;
		else if (sum > n)
			cout << s << endl;
		else
		{
			for (int i = 0; i < n; i++)
			{
				if (s[i] == s[i + 1])
					cnt++;
				else
				{
					cout << cnt << s[i];
					cnt = 1;
				}
			}
			cout << endl;
		}
	}
	return 0;
}